<template>
  <span>
    <slot v-if="initSuccess"></slot>
  </span>
</template>

<script>
export default {
  name: 'LazyLoad',
  props: {
    time: {
      required: false,
      default: 100
    },
    callback: {
      type: Function,
      default: () => {
      }
    }
  },
  data() {
    return {
      initSuccess: false
    }
  },
  created() {
    this.initSlot()
  },

  methods: {
    initSlot() {
      setTimeout(() => {
        this.initSuccess = true
        this.callback()
      }, (Number(this.time || 0)))
    }
  }
}
</script>

<style scoped>

</style>
